//
//  UIButton.swift
//  funcode
//
//  Created by Wan Jiading on 2017/2/15.
//  Copyright © 2017年 WanJiading. All rights reserved.
//

import UIKit

extension UIButton {
	
	convenience init(_ title: String, _ y: CGFloat, _ height: CGFloat, target: Any , action: Selector) {
		self.init()
		self.frame = CGRect(x: CGFloat(50), y: y, width: CGFloat(200), height: height)
		self.setTitle(title, for: .normal)
		self.backgroundColor = UIColor.darkGray
		self.setTitleColor(UIColor.black, for: .normal)
		self.addTarget(target, action: action, for: .touchUpInside)
	}
	
	convenience init(title: String, titleColor: UIColor, backgroundColor: UIColor?, fontSize: CGFloat, target: AnyObject, action: Selector) {
		self.init()
		self.setTitle(title, for: [])
		self.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
		self.titleLabel!.font = UIFont.systemFont(ofSize: fontSize)
		//        self.titleLabel!.font = UIFont.systemFontOfSize(fontSize)
		self.adjustsImageWhenHighlighted = false
		self.setTitleColor(titleColor, for: [])
		if backgroundColor != nil {
			self.backgroundColor = backgroundColor
		}
	}
	
}
